const ws = require('nodejs-websocket')
const POST = 3000
const sever = ws.createServer(connect => {
  console.log('有用户连上来了')
  connect.on('text', data => {
    console.log('接收到了用户的数据', data)
    connect.send(data)
  })
  connect.on('close', () => {
    console.log('连接断开了')
  })
  connect.on('error', () => {
    console.log('用户连接异常')
  })
})
sever.listen(POST, () => {
  console.log('websocket服务启动成功了，监听了端口' + POST)
})